package com.ihg.hiex.entity.user;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 
 * @author downpour
 *
 */
@Entity
@Table(name = "delegate_user")
public class Delegate {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 对应Account */
    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Account account;
    
    /** 头像  */
    private String avatar;
    
    /** 姓名   */
    private String name;
    
    /** 英文名 */
    private String englishName;
    
    private String email;
    
    private String telephone;
    
    private String hotelName;
    
    private String subregion;
    
    private String jobTitle;
    
    /** 目标职位 */
    private String targetPosition;
    
    /** 地区 */
    private String region;
    
    /** 城市*/
    private String city;
    
    /** LineManager */
    private String reportTo;
    
    /** LineManager Email */
    private String reportToEmail;
    
    /** FIXME Coach */
    private String coach;
    
    /** FIXME Coach Email */
    private String coachEmail;
    
    /** FIXME Coach Mobile */
    @Transient
    private String coachMobile;
    
    private Date createTime;
    
    private Date lastModifyTime;
    
    /** 是否首次登陆系统 */
    @Column(name = "is_first_land")
    private boolean firstLand; 
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    @Transient
    private Boolean knowWell;
    
    /**
     * The default constructor.
     */
    public Delegate() {
    }
    
    /**
     * 
     * @param name
     * @param email
     * @param telephone
     * @param hotelName
     * @param subregion
     * @param jobTitle
     * @param reportTo
     * @param reportToEmail
     * @param targetPosition
     * @param region
     * @param city
     */
    public Delegate(String name, String email, String telephone, String hotelName, String subregion, String jobTitle, String reportTo, String reportToEmail, String targetPosition, String region, String city) {
        this.name = name;
        this.email = email.toLowerCase();
        this.telephone = telephone;
        this.hotelName = hotelName;
        this.subregion = subregion;
        this.jobTitle = jobTitle;
        this.reportTo = reportTo;
        this.reportToEmail = reportToEmail;
        this.targetPosition = targetPosition;
        this.region = region;
        this.city = city;
    }
    
    /**
     * 
     * @param account
     * @return
     */
    public Delegate initialize(Account account) {
        this.email = this.email.toLowerCase();
        this.createTime = new Date();
        this.lastModifyTime = new Date();
        this.account = account;
        this.firstLand = true;
        return this;
    }
    
    /**
     * 
     * @param delegate
     * @return
     */
    public Delegate edit(Delegate delegate) {
        this.name = delegate.getName();
        this.email = delegate.getEmail().toLowerCase();
        this.telephone = delegate.getTelephone();
        this.hotelName = delegate.getHotelName();
        this.subregion = delegate.getSubregion();
        this.jobTitle = delegate.getJobTitle();
        this.reportTo = delegate.getReportTo();
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * 
     * @param avatar
     * @return
     */
    public Delegate editAvatar(String avatar) {
    	this.avatar = avatar;
        return this;
    }
        
    /**
     * @return
     */
    public Delegate disable() {
        this.disabled = true;
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * @return 
     * 
     */
    public Delegate edit() {
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * @return
     */
    public Delegate land() {
        this.firstLand = false;
        return this;
    }
    
    /**
     * @return
     */
    @Transient
    public String getIdString() {
        return String.valueOf(id);
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the account
     */
    public Account getAccount() {
        return account;
    }

    /**
     * @return the avatar
     */
    public String getAvatar() {
        return avatar;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the englishName
     */
    public String getEnglishName() {
        return englishName;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @return the telephone
     */
    public String getTelephone() {
        return telephone;
    }

    /**
     * @return the hotelName
     */
    public String getHotelName() {
        return hotelName;
    }

    /**
     * @return the subregion
     */
    public String getSubregion() {
        return subregion;
    }

    /**
     * @return the jobTitle
     */
    public String getJobTitle() {
        return jobTitle;
    }

    /**
     * @return the targetPosition
     */
    public String getTargetPosition() {
        return targetPosition;
    }

    /**
     * @return the region
     */
    public String getRegion() {
        return region;
    }

    /**
     * @return the city
     */
    public String getCity() {
        return city;
    }

    /**
     * @return the reportTo
     */
    public String getReportTo() {
        return reportTo;
    }

    /**
     * @return the reportToEmail
     */
    public String getReportToEmail() {
        return reportToEmail;
    }

    /**
     * @return the coach
     */
    public String getCoach() {
        return coach;
    }

    /**
     * @return the coachEmail
     */
    public String getCoachEmail() {
        return coachEmail;
    }

    /**
     * @return the coachMobile
     */
    public String getCoachMobile() {
        return coachMobile;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * @return the firstLand
     */
    public boolean isFirstLand() {
        return firstLand;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @return the knowWell
     */
    public Boolean getKnowWell() {
        return knowWell;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param account the account to set
     */
    public void setAccount(Account account) {
        this.account = account;
    }

    /**
     * @param avatar the avatar to set
     */
    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param englishName the englishName to set
     */
    public void setEnglishName(String englishName) {
        this.englishName = englishName;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @param telephone the telephone to set
     */
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    /**
     * @param hotelName the hotelName to set
     */
    public void setHotelName(String hotelName) {
        this.hotelName = hotelName;
    }

    /**
     * @param subregion the subregion to set
     */
    public void setSubregion(String subregion) {
        this.subregion = subregion;
    }

    /**
     * @param jobTitle the jobTitle to set
     */
    public void setJobTitle(String jobTitle) {
        this.jobTitle = jobTitle;
    }

    /**
     * @param targetPosition the targetPosition to set
     */
    public void setTargetPosition(String targetPosition) {
        this.targetPosition = targetPosition;
    }

    /**
     * @param region the region to set
     */
    public void setRegion(String region) {
        this.region = region;
    }

    /**
     * @param city the city to set
     */
    public void setCity(String city) {
        this.city = city;
    }

    /**
     * @param reportTo the reportTo to set
     */
    public void setReportTo(String reportTo) {
        this.reportTo = reportTo;
    }

    /**
     * @param reportToEmail the reportToEmail to set
     */
    public void setReportToEmail(String reportToEmail) {
        this.reportToEmail = reportToEmail;
    }

    /**
     * @param coach the coach to set
     */
    public void setCoach(String coach) {
        this.coach = coach;
    }

    /**
     * @param coachEmail the coachEmail to set
     */
    public void setCoachEmail(String coachEmail) {
        this.coachEmail = coachEmail;
    }

    /**
     * @param coachMobile the coachMobile to set
     */
    public void setCoachMobile(String coachMobile) {
        this.coachMobile = coachMobile;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * @param firstLand the firstLand to set
     */
    public void setFirstLand(boolean firstLand) {
        this.firstLand = firstLand;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

    /**
     * @param knowWell the knowWell to set
     */
    public void setKnowWell(Boolean knowWell) {
        this.knowWell = knowWell;
    }
}
